// yingshishipin.entity.ts
import { Shipinleibie } from 'src/admin/shipinleibie/entities/shipinleibie.entity';
import { Yingpingfankui } from 'src/admin/yingpingfankui/entities/yingpingfankui.entity';
import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  ManyToOne,
  JoinColumn,
  OneToMany,
} from 'typeorm';

@Entity('yingshishipin')
export class Yingshishipin {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ comment: '课程编号' })
  shipinbianhao: string;

  @Column({ comment: '课程名称' })
  shipinmingcheng: string;

  @Column({ comment: '课程文件路径', nullable: true })
  shipinwenjian: string;

  @Column({ comment: '封面图片路径', nullable: true })
  fengmiantupian: string;

  @Column({ type: 'text', comment: '备注', nullable: true })
  beizhu: string;

  @CreateDateColumn({ type: 'timestamp', comment: '创建时间' })
  createTime: Date;

  // 原有分类关系
  @ManyToOne(() => Shipinleibie, (leibie) => leibie.yingshishipins, {
    onDelete: 'SET NULL',
  })
  @JoinColumn({ name: 'leibie_id' })
  shipinleibie: Shipinleibie;

  // 新增反馈关系（一对多）
  @OneToMany(() => Yingpingfankui, (feedback) => feedback.shipin)
  feedbacks: Yingpingfankui[];
}
